/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 *  A plot with  a collection of Y axises
 *	The location of Y axises are determined by a single X axis based on attribute of Y axises
 *
 * @author: jin Chen
 * @date: Jun 14, 2003
 * @version: $VERSION$
 */
package edu.psu.geovista.app.plot;



import edu.psu.geovista.app.plot.axis.AxisList;
import edu.psu.geovista.app.plot.axis.XAxisOrder;
import edu.psu.geovista.app.plot.axis.YAxis;

import javax.swing.*;
import java.awt.*;
import java.util.Iterator;

public abstract class MultiYPlot extends JPanel implements MMPlot {
    //public final static int DEFAULT_XAXIS_INTERVAL=150;
    protected AxisList yaxisList;
    protected XAxisOrder xaxis;
    //protected int numOfAxis;//num of YAxis

    //size
    protected Dimension activeSize;
    //protected Dimension size;
    protected Point offset;// the starting point of plot
    private Point xaxisOffset=new Point();// 
    public MultiYPlot(){

    }
    /*public MultiYPlot(AppDataModel dataModel) {
        //this.numOfAxis= dataModel.getNumDimensions() ;
     }*/



    public void setActiveSize(Dimension activeSize) {
        this.activeSize = activeSize;
        //update XAxis
        this.xaxis.setActiveSize(activeSize.width );
        Iterator iter=yaxisList.iterator() ;
        while(iter.hasNext() ){
             YAxis yaxis=(YAxis)iter.next() ;
             yaxis.setActiveSize(activeSize.height);
        }
        //update YAxis
    }

    /*protected void createX(int activeSize,Extreme dataRange, String axisName){
        this.xaxis =new XAxis(activeSize,dataRange,axisName);
        this.xaxis.setAxisLocation(this.getOffset().x, this.getOffset().y);
    }*/



    /*******************************************************************************************************
     *                bound
     *******************************************************************************************************/
    public Dimension getActiveSize() {
        return activeSize;
    }
    /**
     *  only Called by A

    public void setActiveSize(Dimension activeSize) {
        this.activeSize = activeSize;
    } */
    /*
    public Dimension getSize() {

        return size;
    }

    public void setSize(Dimension size) {
        this.size = size;
    }       */
    /*
    public void setPerferedSize(int w, int h) {
        System.out.println("MultiPlot.setPerferedSize()");
    }            */
    public Point getOffset() {
        return offset;
    }

    public void setOffset(Point offset) {
        this.offset = offset;
    }

    public Point getXaxisOffset() {
        return xaxisOffset;
    }

    public void setXaxisOffset(Point xaxisOffset) {
        this.xaxisOffset.setLocation(xaxisOffset);
    }

    public edu.psu.geovista.app.plot.axis.XAxisOrder getXaxis() {
        return xaxis;
    }

    public AxisList getYaxisList() {
        return yaxisList;
    }
    public Dimension getPreferredSize(){
        return super.getPreferredSize() ;

    }
    /*
    public YAxis getAxis(int displayIndex){
        Iterator iter=yaxisList.iterator() ;
          while(iter.hasNext() ){
              YAxis axis=(YAxis)iter.next() ;
              if (axis.getIndex()==displayIndex){
                  return axis;
              }
          }
          return null;
     }   */

}
